﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Deeper.Controls
{
	/// <summary>
	/// 这是分页控件，生成页码用的
	/// </summary>
	[Serializable]
	public class PageNumber
	{
		/// <summary>
		/// 开始页码，最小为0
		/// </summary>
		public int sIndex { private set; get; }
		/// <summary>
		/// 截止页码，不超过页码最大数
		/// </summary>
		public int eIndex { private set; get; }
		/// <summary>
		/// 当前页
		/// </summary>
		public int currentIndex { set; get; }
		/// <summary>
		/// 总页数
		/// </summary>
		public int pageCount { set; get; }

		public PageNumber(int pageCount, int currentIdex)
		{
			this.currentIndex = currentIndex;
			this.pageCount = pageCount;

			this.sIndex = currentIdex - 2;
			this.eIndex = currentIdex + 2;
			if (this.sIndex < 1)
			{
				this.sIndex = 1;
				this.eIndex = this.sIndex + 4;
			}

			if (this.eIndex > pageCount)
			{
				this.eIndex = pageCount;
				this.sIndex = this.eIndex - 4;
				if (this.sIndex < 1)
					this.sIndex = 1;
			}
		}
	}

}
